﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MadProps.TypeDescription
{
    class PropModelDescriptor : BasePropertyDescriptor
    {
        readonly PropModel propModel;

        public PropModelDescriptor(PropModel propModel, string name)
            : base(name, null)
        {
            this.propModel = propModel.ThrowIfNull("propModel");
        }

        public override Type ComponentType
        {
            get { return propModel.Prop.Owner.GetType(); }
        }

        public override object GetValue(object component)
        {
            return propModel;
        }

        public override bool IsReadOnly
        {
            get { return true; }
        }

        public override Type PropertyType
        {
            get { return propModel.GetType(); }
        }

        public override void SetValue(object component, object value)
        {
            throw new InvalidOperationException();
        }
    }
}
